<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: CHJYPC
  Date: 2021/6/1
  Time: 23:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>导入培养方案</title>
    <link rel="stylesheet" type="text/css" href="${rootPath}resources/css/importDataPlain.css"/>
</head>
<body>

<div class="wrapper">
    <div class="divleft">


        <div class="bar1">
            <button onclick="openMajor()">添加专业</button>

        </div>
        <c:set var="sum" value="1"/>
        <table class="mainTable">

            <tr>
                <th>专业编号</th>
                <th>专业名称</th>
                <th>操作</th>
            </tr>
            <c:forEach var="list" items="${AllMajor}">
                <tr>
                    <td> ${list.majorID}</td>
                    <td> ${list.majorName}</td>
                    <td>
                        <div class="opUpdateOrdelete">
                            <a href="javaScript:seePlain('${list.majorID}')" class="small blue button">查看方案</a>
                            <a href="javascript:updateMajoe('${list.majorID}',' ${list.majorName}')"
                               class="small red button">编辑</a>
                        </div>
                    </td>
                </tr>
                <c:set var="sum" value="${sum+1}"/>
            </c:forEach>
        </table>
    </div>
    <div class="divright">


        <div class="divplan">


            <div class="divInputFile">
                <form enctype="multipart/form-data" action="imporPlanFileServlet" method="post">
                    导入培养方案，选择一个文件:
                    <%--<input type="text" name="op" value="submitfile" hidden>--%>
                    <%--<input type="text" name="majorid" value="100" hidden>--%>
                    <input type="file" name="uploadFile"/>
                    <input type="submit" value="上传"/>
                </form>
                <c:forEach var="name" items="${fileList}">
                    <div>
                            ${name}
                    </div>
                </c:forEach>

            </div>


            <table class="mainTable">
                <tr>
                    <th colspan="10"><h3>培养方案列表</h3></th>
                </tr>
                <tr>
                    <th>专业ID</th>
                    <th>年级</th>
                    <th>任选学分</th>
                    <th>限选学分</th>
                    <th>专业必修学分</th>
                    <th>通识必修学分</th>
                    <th>通识选修学分</th>
                    <th>学科基础学分</th>
                    <th>实践环境</th>
                    <th>操作</th>
                </tr>
                <c:set var="sum" value="1"/>
                <c:forEach var="list" items="${plain}">
                    <tr>
                            <%--trainplanId--%>
                        <td> ${list.majorId}</td>
                        <td> ${list.grade}</td>
                        <td> ${list.optionalCredit}</td>
                        <td> ${list.limiteCredit}</td>
                        <td> ${list.professionalRequired}</td>
                        <td> ${list.generalRequired}</td>
                        <td> ${list.generalElective}</td>
                        <td> ${list.disciplineBasis}</td>
                        <td> ${list.practiceLink}</td>
                        <td>
                            <div class="opUpdateOrdelete">
                                <a href="javaScript:seePlaincourse('${list.majorId}','${list.trainplanId}')"
                                   class="small blue button">查看包含课程</a>
                                <a href="javaScript:editPlain(
                                '${list.trainplanId}',
                                '${list.majorId}',
                                '${list.grade}',
                                '${list.optionalCredit}',
                                '${list.limiteCredit}',
                                '${list.professionalRequired}',
                                '${list.generalRequired}',
                                '${list.generalElective}',
                                '${list.disciplineBasis}',
                                '${list.practiceLink}'
                                )" class="small blue button">编辑</a>
                                    <%--<a href="javascript:void(0)" class="small red button"></a>--%>
                            </div>
                        </td>

                        <c:set var="sum" value="${sum+1}"/>
                    </tr>
                </c:forEach>
            </table>

        </div>
        <div class="divcounrse">

            <table class="mainTable">
                <tr>
                    <th>序号</th>
                    <th>课程名称</th>
                    <th>学期安排</th>
                    <th>学分</th>
                    <th>课程类型</th>
                    <th>课时</th>
                    <th>是否核心课程</th>
                    <th>操作</th>
                </tr>
                <c:set var="sum" value="1"/>
                <c:forEach var="list" items="${plaincourse}">
                    <tr>
                        <td>${sum}</td>
                        <td> ${list.courseName}</td>
                        <td> ${list.planCourseTerm}</td>
                        <td> ${list.credit}</td>
                        <td> ${list.courseType}</td>
                        <td> ${list.courseHours}</td>
                        <td> ${list.courseLevel==1? "是":"否"}</td>

                        <td>
                            <div class="opUpdateOrdelete">
                                    <%--<a href="javaScript:seePlaincourse('${list.majorId}','${list.trainplanId}')"--%>
                                    <%--class="small blue button">查看</a>--%>
                                <a href="javaScript:updateCourse(
                                '${list.trainplancourseId}'
                                ,'${list.trainplanId}'
                                ,'${list.courseName}'
                                ,'${list.planCourseTerm}'
                                ,'${list.credit}'
                                ,'${list.courseType}'
                                ,'${list.courseHours}'
                                ,'${list.courseLevel}')" class="small blue button">编辑</a>
                                <%--<a href="javascript:void(0)"  class="small red button">删除</a>--%>
                            </div>
                        </td>
                        <c:set var="sum" value="${sum+1}"/>
                    </tr>
                </c:forEach>
            </table>
        </div>


    </div>
    <%--发送查询培养方案请求--%>
    <form action="importPlanServlet" id="formPlain" method="post" style="display: none">
        <input type="text" name="op" value="getAllPlain">
        <input type="text" name="majorid" id="majorid" value="">
    </form>
    <%--查询培养方案的课程--%>
    <form action="importPlanServlet" id="formPlainCourse" method="post" style="display: none">
        <input type="text" name="majorid" id="majoridCourse" value="">
        <input type="text" name="op" value="getAllPlainCourse">
        <input type="text" name="trainplain" id="trainpain" value="">
    </form>
    <%--弹窗--%>
    <div class="openDiv" id="divSee" style="display: none">
        <input type="button" class="closeInput" value="关闭" onclick="closeOpen('divSee')">
        <div>
            <form id="addOrUpdateMajorForm" action="importPlanServlet" method="post">
                <input type="text" name="op" id="auOP" hidden value="addmajor">
                <input type="text" name="majorid" id="upmajorId" hidden value="">
                专业名称 <input type="text" name="majorname" id="majorName" value="">
                <input type="submit" value="保存" onclick="return saveMajor(this.form)">
            </form>
        </div>
    </div>
    <%--弹窗修改培养方案--%>
    <div class="openDivUP" id="divUPplain" style="display: none">
        <input type="button" class="closeInput" value="关闭" onclick="closeOpen('divUPplain')">
        <ul>
            <form id="" method="post" action="importPlanServlet">
                <input name="op" value="updateplain" hidden>
                <li><input name="trainplanId" id="trainplanIdup" value="" readonly hidden></li>
                <li>专业ID <input name="majorId" id="majorIdup" readonly value=""></li>
                <li>年级 <input name="grade" id="gradeup" value=""></li>
                <li>任选学分<input name="optionalCredit" id="optionalCreditup" value=""></li>
                <li>限选学分<input name="limiteCredit" id="limiteCreditup" value=""></li>
                <li>专业必修学分<input name="professionalRequired" id="professionalRequiredup" value=""></li>
                <li>通识必修学分<input name="generalRequired" id="generalRequiredup" value=""></li>
                <li>通识选修学分<input name="generalElective" id="generalElectiveup" value=""></li>
                <li>学科基础学分<input name="disciplineBasis" id="disciplineBasisup" value=""></li>
                <li>实践环境<input name="practiceLink" id="practiceLinkup" value=""></li>
                <li><input type="submit" value="提交"></li>
            </form>
        </ul>
    </div>

    <%--弹窗修改培养方案的乐橙--%>
    <div class="openDivUP" id="divUPplainCourse" style="display: none">
        <input type="button" class="closeInput" value="关闭" onclick="closeOpen('divUPplainCourse')">
        <ul>
            <form method="post" action="importPlanServlet">
                <input name="op" value="updateplaincourse" hidden>
                <li><input name="trainplancourseIdup" id="trainplancourseIdup" value=""  hidden></li>
                <li> <input name="trainplanIdcup" id="trainplanIdcup"  value="" hidden></li>
                <li>课程名称 <input name="courseNameup" id="courseNameup" value=""></li>
                <li>学期安排<input name="planCourseTermup" id="planCourseTermup" value=""></li>
                <li>学分<input name="creditup" id="creditup" value=""></li>
                <li>课程类型<input name="courseTypeup" id="courseTypeup" value=""></li>
                <li>课时<input name="courseHoursup" id="courseHoursup" value=""></li>
                <li>是否核心课程<input name="courseLevelup" id="courseLevelup" value=""></li>
                <li><input type="submit" value="提交"></li>
            </form>
        </ul>
    </div>

    <%--<form enctype="multipart/form-data"  action="importPlanServlet" method="post">--%>
    <%--选择一个文件:--%>
    <%--<input type="file" name="uploadFile"   />--%>
    <%--<br/><br/>--%>
    <%--<input type="submit" value="上传" />--%>
    <%--</form>--%>
    <%--<c:forEach var="name" items="${fileList}">--%>
    <%--<div>--%>
    <%--${name}--%>
    <%--</div>--%>
    <%--</c:forEach>--%>


</div>


</body>
<script type="text/javascript">

    function seePlain(majorid) {
        // alert(majorid)

        if (majorid == null || majorid.length <= 0) {
            alert("获取专业id失败！")
            return;
        }
        document.getElementById("majorid").value = majorid;
        document.getElementById("formPlain").submit();


    }

    function seePlaincourse(majorid, trainplainid) {
        // alert(majorid + ":" + trainplainid)

        // if (id == null || id.length <= 0) {
        //     alert("获取公告id失败！")
        //     return;
        // }
        document.getElementById("majoridCourse").value = majorid;
        document.getElementById("trainpain").value = trainplainid;
        document.getElementById("formPlainCourse").submit();

    }

    function openMajor() {
        document.getElementById("auOP").value = "addmajor";
        document.getElementById("majorName").value = "";
        document.getElementById("divSee").setAttribute("style", " display: block;");
    }

    //关闭编辑窗
    function closeAnnouncement() {
        document.getElementById("divSee").setAttribute("style", " display: none;");

    }

    function closeOpen(item) {
        document.getElementById(item).setAttribute("style", " display: none;");
    }

    function saveMajor() {

        document.getElementById("addOrUpdateMajorForm").submit();
    }

    function updateMajoe(majorid, majorname) {

        document.getElementById("auOP").value = "updatemajor";
        document.getElementById("upmajorId").value = majorid;
        document.getElementById("majorName").value = majorname;
        document.getElementById("divSee").setAttribute("style", " display: block;");
    }

    function editPlain(trainplanId, majorId, grade, optionalCredit, limiteCredit,
                       professionalRequired, generalRequired, generalElective,
                       disciplineBasis, practiceLink) {
        document.getElementById("trainplanIdup").value = trainplanId;
        document.getElementById("majorIdup").value = majorId;
        document.getElementById("gradeup").value = grade;
        document.getElementById("optionalCreditup").value = optionalCredit;
        document.getElementById("limiteCreditup").value = limiteCredit;
        document.getElementById("professionalRequiredup").value = professionalRequired;
        document.getElementById("generalRequiredup").value = generalRequired;
        document.getElementById("generalElectiveup").value = generalElective;
        document.getElementById("disciplineBasisup").value = disciplineBasis;
        document.getElementById("practiceLinkup").value = practiceLink;

        document.getElementById("divUPplain").setAttribute("style", " display: block;");
    }
function updateCourse(trainplancourseId,
                      trainplanId,
                      courseName,
                      planCourseTerm,
                      credit,
                      courseType,
                      courseHours,
                      courseLevel) {
    document.getElementById("trainplancourseIdup").value = trainplancourseId;
    document.getElementById("trainplanIdcup").value = trainplanId;
    document.getElementById("courseNameup").value = courseName;
    document.getElementById("planCourseTermup").value = planCourseTerm;
    document.getElementById("creditup").value = credit;
    document.getElementById("courseTypeup").value = courseType;
    document.getElementById("courseHoursup").value = courseHours;
    document.getElementById("courseLevelup").value = courseLevel;
    document.getElementById("divUPplainCourse").setAttribute("style", " display: block;");

}
</script>

</html>
